<?php

App::uses('AppController', 'Controller');

class ConfigsController extends AppController{
	
	var $uses = null;
	
	function beforeFilter(){
		parent::beforeFilter();
		if(!$this->admin()){
			throw new MethodNotAllowedException(__('Opção inválida'));
		}
	}
	
	public function index(){
		if(!empty($this->request->data)){
			if($this->configs->save($this->request->data))
				$this->Session->setFlash(__('Configurações salvas'));
			else $this->Session->setFflash(__('Erro ao salvar! Tente novamente'));
		}
		else{
			$this->request->data = $this->configs->getDados();
		}
	}
	
}